﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace SCM.Common.SMS
{
    public class SharePushModel
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("source")]
        public string Source { get; set; } = "webapi";

        /// <summary>
        /// APPKEY（方法会在内部自动填写）
        /// </summary>
        [JsonProperty("appkey")]
        public string Appkey { get; set; }

        /// <summary>
        /// 推送目标
        /// </summary>
        [JsonProperty("pushTarget")]
        public PushTarget PushTarget { get; set; }

        /// <summary>
        /// 推送内容
        /// </summary>
        [JsonProperty("pushNotify")]
        public PushNotify PushNotify { get; set; }

        /// <summary>
        /// 跳转动作
        /// </summary>
        [JsonProperty("pushForward")]
        public PushForward PushForward { get; set; }
    }
    /// <summary>
    /// 推送模板
    /// </summary>
    public class PushTarget
    {
        /// <summary>
        /// 推送类型
        /// </summary>
        [JsonProperty("target")]
        public TargetEnum Target { get; set; }

        /// <summary>
        /// target:4设置推送Registration
        /// </summary>
        [JsonProperty("rids")]
        public List<string> Rids { get; set; }

        /// <summary>
        ///  target:3 => 设置推送标签集合["tag1", "tag2"]
        /// </summary>
        [JsonProperty("tags")]
        public List<string> Tags { get; set; }

        /// <summary>
        /// target:3 => 标签组合方式：1并集；2交集；3补集(3暂不考虑)
        /// </summary>
        [JsonProperty("tagsType")]
        public int? TagsType { get; set; } = 1;

        /// <summary>
        ///  target:2 => 设置推送别名集合["alias1", "alias2"]
        /// </summary>
        [JsonProperty("alias")]
        public List<string> Alias { get; set; }


        /// <summary>
        /// target:6 => 用户分群ID
        /// </summary>
        [JsonProperty("block")]
        public List<string> Block { get; set; }

        /// <summary>
        /// target:5 => 推送地理位置 城市，地理位置推送时，city, province, country 必须有一个不为空
        /// </summary>
        [JsonProperty("city")]
        public string City { get; set; }
        /// <summary>
        ///  target:5 => 推送地理位置 省份，地理位置推送时，city, province, country 必须有一个不为空
        /// </summary>
        [JsonProperty("province")]
        public string Province { get; set; }
        /// <summary>
        /// target:5 => 推送地理位置 国家，地理位置推送时，city, province, country 必须有一个不为空
        /// </summary>
        [JsonProperty("country")]
        public string Country { get; set; }
    }

    /// <summary>
    /// 推送内容
    /// </summary>
    public class PushNotify
    {
        /// <summary>
        /// 1 android;2 ios
        /// </summary>
        [JsonProperty("plats")]
        public List<int> Plats { get; set; }

        /// <summary>
        /// 离线消息保存时间，默认0
        /// </summary>
        [JsonProperty("offlineSeconds")]
        public int OfflineSeconds { get; set; }

        /// <summary>
        /// 推送内容
        /// </summary>
        [JsonProperty("content")]
        public string Content { get; set; }

        /// <summary>
        /// 如果不设置，则默认的通知标题为应用的名称。如果标题长度超过厂商的限制, 则标题会被截断. vivo不允许纯表情。
        /// </summary>
        [JsonProperty("title")]
        public string Title { get; set; }

        /// <summary>
        /// 如果不设置，则默认的通知标题为应用的名称。如果标题长度超过厂商的限制, 则标题会被截断. vivo不允许纯表情。
        /// </summary>
        [JsonProperty("type")]
        public PushTypeEnum Type { get; set; }

        /// <summary>
        /// 消息的参数内容
        /// </summary>
        [JsonProperty("extrasMapList")]
        public List<KeyValue> ExtrasMapList { get; set; }
    }

    public class PushForward
    {
        /// <summary>
        /// 1 link跳转 moblink功能的的uri 否
        /// </summary>
        [JsonProperty("url")]
        public string Url { get; set; }

        /// <summary>
        /// 2 scheme moblink功能的的scheme 是
        /// </summary>
        [JsonProperty("scheme")]
        public string Scheme { get; set; }

        /// <summary>
        /// schema参数   否
        /// </summary>
        [JsonProperty("schemeDataList")]
        public List<KeyValue> SchemeDataList { get; set; }
        /// <summary>
        /// 跳转方式0 打开首页 1 link跳转 2 scheme 跳转
        /// </summary>
        [JsonProperty("nextType")]
        public NextTypeEnum NextType { get; set; }
    }

    public class KeyValue
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("key")]
        public string Key { get; set; }
        [JsonProperty("value")]
        public string Value { get; set; }
    }

    public enum NextTypeEnum
    {
        /// <summary>
        /// 打开首页
        /// </summary>
        Home = 0,
        /// <summary>
        /// link跳转
        /// </summary>
        Link = 1,
        /// <summary>
        /// scheme 跳转
        /// </summary>
        Scheme = 2
    }
    public enum TargetEnum
    {

        All=1,
        /// <summary>
        /// 2别名
        /// </summary>
        Alias = 2,
        /// <summary>
        /// 3标签
        /// </summary>
        Tags = 3,
        /// <summary>
        /// Regid
        /// </summary>
        Rids = 4,
        /// <summary>
        /// 地理位置
        /// </summary>
        Address = 5,
        /// <summary>
        /// 用户分群
        /// </summary>
        Block = 6,

    }

    public enum PushTypeEnum
    {
        /// <summary>
        /// 通知栏消息
        /// </summary>
        Message=1,
        /// <summary>
        /// 透传消息
        /// </summary>
        Passthrough=2,
    }
}
